<?include "../top.php";
//echo $INCOME['submit'];
$dealerArr["21"] = array("id"=>21,"name"=>"上海东联","pass"=>"445566");
$dealerArr["22"] = array("id"=>22,"name"=>"上海信佳","pass"=>"373737");
$dealerArr["23"] = array("id"=>23,"name"=>"上海名创","pass"=>"889988");
$dealerArr["24"] = array("id"=>24,"name"=>"上海越也","pass"=>"989898");
$dealerArr["25"] = array("id"=>25,"name"=>"中进名创","pass"=>"565656");
if($INCOME['submit']=="0")
{
	if($INCOME['name'] && $INCOME['dealerId']!="0")
	{
		$dealer = $DB->db_query_first("select * from dealer_info where id = ".$INCOME['dealerId']);
		if($dealer)
		{
			$user =$DB->db_query_first("select * from user_info where name='".$INCOME['name']."'");
			if($user)
			{
				echo "账号已经存在";
			}
			else
			{
				$f['name'] = $INCOME['name'];
				$f['pass'] = md5($dealerArr[$INCOME['dealerId']]["pass"]);
				$f['dealerId'] = $dealer['id'];
				$f['dealerName'] = $dealer['name'];
				$f['addTime']=$GCurTime;
				$DB->db_form_insert("user_info",$f);
				echo "保存成功";
			}
		}
	}
	else
	{
		echo "经销商必选 账号名必填";
	}
	//echo "<script>window.location.href='userMgr.php';</script>";
}
else if($INCOME['submit'] >0)
{
	echo "啊啊啊啊";
}
?>
<form name="form" action="" method="post" >
选择经销商<select name="dealerId">
<option value="0">选择经销商</option>
<?foreach($dealerArr as $v){?>
<option value="<?echo $v['id']?>" <?if($INCOME['dealerId']==$v['id']){echo "selected";}?>><?echo $v['name']?> 密码:<?echo $v['pass']?></option>
<?}?>
</select>
账号<input name="name" id="" value=""/>
<input type="hidden" name="submit" value="0"/>
<input type="submit" name="ttt" value="保存"/>
</form>
<?
$DB->db_query("select * from user_info where addTime >'2013-04-01' and name not like '%test%' order by addTime desc");
?>
<table width="100%"/>
<?
while($r=$DB->db_fetch_row())
{
?>
<tr><td width="10%"><?echo $r['name']?></td><td><?echo $r['dealerName']?></td>
<?
}
?>